package com.qd.dict.sys;

import com.cdqidi.dict.annotation.FieldBind;
import com.cdqidi.dict.config.IFieldProcess;
import com.qd.common.dict.DictConstant;
import com.qd.system.util.FileConfirmUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * 角色名字转换
 *
 * @author sjk
 */
@Component
@RequiredArgsConstructor
@Lazy
public class SysFileProcessImpl implements IFieldProcess {

    @Override
    public String processName() {
        return DictConstant.SYS_FILE_CONFIRM;
    }

    @Override
    public Object convertValue(FieldBind fieldBind, Object fieldValue) {
        if (null == fieldValue) {
            return "";
        }
        String url = fieldValue.toString();
//        if (url.startsWith(ConstantDto.HTTP)) {
//            return url;
//        }
        return FileConfirmUtil.getImageFile(url);
    }
}